package huang.com.android.autocompetetextview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.MultiAutoCompleteTextView;

public class AutoAcitvity extends AppCompatActivity {
    private static final String[] autostr = new String[] {"abc","abcd","abcde"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.auto_acitvity);
        /*new arrayadapter对象并将autostr数组传入*/
        ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line,autostr);

        AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.myAutoCompleteTextView);

        autoCompleteTextView.setAdapter(adapter);

        MultiAutoCompleteTextView myMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.myMultiAutoCompleteTextView);

        myMultiAutoCompleteTextView.setAdapter(adapter);

        myMultiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
    }
}
